#ifndef TASKTIMER_H
#define TASKTIMER_H

#include <QObject>
#include <QLCDNumber>
#include <QTimer>
#include <QLabel>
#include "taskitem.h"
#include <QSoundEffect>
#include <QApplication>
#include <QPushButton>

using timeVec = QPair<QTime, QTime>;
using timeVecs = QVector<timeVec>;

class taskTimer : public QObject
{
    Q_OBJECT

private:
    QLabel *m_today_count_total;
    QLCDNumber *m_lcdNumber;
    QTimer *m_timer;
    QLabel *m_state_label;
    QPushButton *m_start_btn;
    QPushButton *m_stop_btn;

    int m_counts = 0;   //时间计数

    // 计时器到期提示音
    QSoundEffect *m_timer_end_effect;


    bool m_time_vec_flag=false;
    timeVecs m_time_vecs;
    timeVec m_time_vec;

public:
    enum taskState {WORK, REST};
    taskState m_task_state;


public:
    explicit taskTimer(QObject *parent = nullptr);
    explicit taskTimer(QLabel *today_count_total, QLCDNumber *lcdNumber, QTimer *timer, QLabel *state_label, QPushButton *startBtn, QPushButton *stopBtn, QObject *parent = nullptr);


    bool isActivate();

    void lcdDisplay(int count);

    void resetCount();
    void stateSwitch();

    void Init();

    void TaskStart();
    void TaskPause();
    void TaskReset();
    void TaskEnd();
    void timerTick();

    void bellPlay();
signals:
    void SendTaskEndSignal(timeVecs *ptime_vecs);

};

#endif // TASKTIMER_H
